DiscGolf = {

    applicationName: '',
    
    golferId: '',

    CommonLib: {

        makeEl: function( elString ) { return $( document.createElement( elString ) ); },

        centerEl: function( p ) {

            p.el.css( { top: parseInt( ( p.parentEl.outerHeight( true ) - p.el.outerHeight( true ) ) / 2 ),
                        left: parseInt( ( p.parentEl.outerWidth( true ) - p.el.outerWidth( true ) ) / 2 ) } );

            return p.el;
        },

        makeUrl: function( p ) {

            var url = [ '/', DiscGolf.applicationName, '/', p.controller ];

            if( p.argList ) {
                for( var i = 0, ii = p.argList.length; i < ii; i++ ) { url.push( [ '/', p.argList[i] ].join('') ); }
            }

            return url.join('');
        },

        isMouseOnElement: function( p ) {

            var elementOffset = p.el.offset();

            if( p.x < elementOffset.left || p.y < elementOffset.top ||
                p.x > ( elementOffset.left + p.el.outerWidth( true ) ) ||
                p.y > ( elementOffset.top + p.el.outerHeight( true ) ) ) { 

                    return false;

            } else { return true; }
        },

        logWithBase: function( n, base ) {

            return Math.log( n ) / ( base ? Math.log( base ) : 1 );
        },

        evaluateJson: function( jsonString ) {
            
            return eval( '(' + jsonString + ')' );
        }

    },

    Views: { },

    Models: { },

    Collections: { },

    BootstrappedData: { }

}

Backbone.View.prototype.makeEl = DiscGolf.CommonLib.makeEl;
Backbone.View.prototype.centerEl = DiscGolf.CommonLib.centerEl;
